package org.xtext.tp4.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import org.xtext.tp4.minigobstones.Black;
import org.xtext.tp4.minigobstones.Blue;
import org.xtext.tp4.minigobstones.East;
import org.xtext.tp4.minigobstones.Green;
import org.xtext.tp4.minigobstones.HayBolitas;
import org.xtext.tp4.minigobstones.IfElse;
import org.xtext.tp4.minigobstones.InitStructure;
import org.xtext.tp4.minigobstones.MinigobstonesPackage;
import org.xtext.tp4.minigobstones.Move;
import org.xtext.tp4.minigobstones.North;
import org.xtext.tp4.minigobstones.ProcedureDef;
import org.xtext.tp4.minigobstones.Put;
import org.xtext.tp4.minigobstones.Red;
import org.xtext.tp4.minigobstones.South;
import org.xtext.tp4.minigobstones.West;
import org.xtext.tp4.services.MinigobstonesGrammarAccess;

@SuppressWarnings("all")
public class MinigobstonesSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private MinigobstonesGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == MinigobstonesPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case MinigobstonesPackage.BLACK:
				if(context == grammarAccess.getBlackRule() ||
				   context == grammarAccess.getTypeColorRule()) {
					sequence_Black(context, (Black) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.BLUE:
				if(context == grammarAccess.getBlueRule() ||
				   context == grammarAccess.getTypeColorRule()) {
					sequence_Blue(context, (Blue) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.EAST:
				if(context == grammarAccess.getEastRule() ||
				   context == grammarAccess.getTypeMovementRule()) {
					sequence_East(context, (East) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.GREEN:
				if(context == grammarAccess.getGreenRule() ||
				   context == grammarAccess.getTypeColorRule()) {
					sequence_Green(context, (Green) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.HAY_BOLITAS:
				if(context == grammarAccess.getConditionRule() ||
				   context == grammarAccess.getHayBolitasRule()) {
					sequence_HayBolitas(context, (HayBolitas) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.IF_ELSE:
				if(context == grammarAccess.getCommandsRule() ||
				   context == grammarAccess.getIfElseRule()) {
					sequence_IfElse(context, (IfElse) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.INIT_STRUCTURE:
				if(context == grammarAccess.getInitStructureRule()) {
					sequence_InitStructure(context, (InitStructure) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.MOVE:
				if(context == grammarAccess.getCommandsRule() ||
				   context == grammarAccess.getMoveRule()) {
					sequence_Move(context, (Move) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.NORTH:
				if(context == grammarAccess.getNorthRule() ||
				   context == grammarAccess.getTypeMovementRule()) {
					sequence_North(context, (North) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.PROCEDURE_DEF:
				if(context == grammarAccess.getDefinitionRule() ||
				   context == grammarAccess.getProcedureDefRule()) {
					sequence_ProcedureDef(context, (ProcedureDef) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.PUT:
				if(context == grammarAccess.getCommandsRule() ||
				   context == grammarAccess.getPutRule()) {
					sequence_Put(context, (Put) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.RED:
				if(context == grammarAccess.getRedRule() ||
				   context == grammarAccess.getTypeColorRule()) {
					sequence_Red(context, (Red) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.SOUTH:
				if(context == grammarAccess.getSouthRule() ||
				   context == grammarAccess.getTypeMovementRule()) {
					sequence_South(context, (South) semanticObject); 
					return; 
				}
				else break;
			case MinigobstonesPackage.WEST:
				if(context == grammarAccess.getTypeMovementRule() ||
				   context == grammarAccess.getWestRule()) {
					sequence_West(context, (West) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     name='Negro'
	 */
	protected void sequence_Black(EObject context, Black semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getBlackAccess().getNameNegroKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Azul'
	 */
	protected void sequence_Blue(EObject context, Blue semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getBlueAccess().getNameAzulKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Este'
	 */
	protected void sequence_East(EObject context, East semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getEastAccess().getNameEsteKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Verde'
	 */
	protected void sequence_Green(EObject context, Green semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getGreenAccess().getNameVerdeKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name='hayBolitas' type=TypeColor)
	 */
	protected void sequence_HayBolitas(EObject context, HayBolitas semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.HAY_BOLITAS__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.HAY_BOLITAS__NAME));
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.HAY_BOLITAS__TYPE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.HAY_BOLITAS__TYPE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getHayBolitasAccess().getNameHayBolitasKeyword_0_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getHayBolitasAccess().getTypeTypeColorParserRuleCall_2_0(), semanticObject.getType());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name='if' type=Condition commands+=Commands* commands+=Commands*)
	 */
	protected void sequence_IfElse(EObject context, IfElse semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     definitions+=Definition*
	 */
	protected void sequence_InitStructure(EObject context, InitStructure semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name='Mover' type=TypeMovement)
	 */
	protected void sequence_Move(EObject context, Move semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.COMMANDS__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.COMMANDS__NAME));
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.MOVE__TYPE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.MOVE__TYPE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getMoveAccess().getNameMoverKeyword_0_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getMoveAccess().getTypeTypeMovementParserRuleCall_2_0(), semanticObject.getType());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Norte'
	 */
	protected void sequence_North(EObject context, North semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getNorthAccess().getNameNorteKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID commands+=Commands*)
	 */
	protected void sequence_ProcedureDef(EObject context, ProcedureDef semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name='Poner' type=TypeColor)
	 */
	protected void sequence_Put(EObject context, Put semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.COMMANDS__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.COMMANDS__NAME));
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.PUT__TYPE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.PUT__TYPE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPutAccess().getNamePonerKeyword_0_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getPutAccess().getTypeTypeColorParserRuleCall_2_0(), semanticObject.getType());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Rojo'
	 */
	protected void sequence_Red(EObject context, Red semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_COLOR__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getRedAccess().getNameRojoKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Sur'
	 */
	protected void sequence_South(EObject context, South semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getSouthAccess().getNameSurKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name='Oeste'
	 */
	protected void sequence_West(EObject context, West semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MinigobstonesPackage.Literals.TYPE_MOVEMENT__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getWestAccess().getNameOesteKeyword_0(), semanticObject.getName());
		feeder.finish();
	}
}
